home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------
- // HollowFontWidened.cs ⌐ 2001 by Charles Petzold
- //------------------------------------------------
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
-
- class HollowFontWidened: FontMenuForm
- {
- public new static void Main()
- {
- Application.Run(new HollowFontWidened());
- }
- public HollowFontWidened()
- {
- Text = "Fuente hueca (Extendida)";
- Width *= 2;
- strText = "Extendida";
- font = new Font("Times New Roman", 108,
- FontStyle.Bold | FontStyle.Italic);
- }
- protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
- {
- GraphicsPath path = new GraphicsPath();
- float fFontSize = PointsToPageUnits(grfx, font);
-
- // A±adir texto al trazado.
-
- path.AddString(strText, font.FontFamily, (int) font.Style,
- fFontSize, new PointF(0, 0), new StringFormat());
-
- // Obtener los lφmites del trazado para el centrado.
-
- RectangleF rectfBounds = path.GetBounds();
-
- grfx.TranslateTransform(
- (cx - rectfBounds.Width) / 2 - rectfBounds.Left,
- (cy - rectfBounds.Height) / 2 - rectfBounds.Top);
-
- // Extender, llenar y dibujar el trazado.
-
- path.Widen(new Pen(Color.Black, fFontSize / 20));
- Brush brush = new HatchBrush(HatchStyle.Trellis,
- Color.White, Color.Black);
- grfx.DrawPath(new Pen(Color.Black, 2), path);
- grfx.FillPath(brush, path);
- }
- }